package com.hornsun.data.constant.types;

/**
 * <p>
 * 该文件的作用：//TODO
 * </p>
 *
 * @author xuxin
 * @date 2018/8/29
 */
public class ReturnType<T> {
    private T data;
    private Integer status;
    private ReturnErrorContext error;
    private ReturnType(){}

    /**
     * 实例化返回值类型
     * @param statusEnum StatusEnum类型
     */
    public ReturnType(StatusEnum statusEnum){
        this.status = statusEnum.getCode();
    }

    /**
     * 返回错误码
     * @param error
     */
    public ReturnType(ReturnErrorContext error){
        this.status = StatusEnum.ERROR.getCode();
        this.error = error;
    }

    /**
     * 返回正常操作数据
     * @param data
     */
    public ReturnType(T data){
        this.status = StatusEnum.SUCCESS.getCode();
        this.data = data;
    }

    public Object getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Integer getStatus() {
        return status;
    }

    public ReturnErrorContext getError() {
        return error;
    }

    public void setError(ReturnErrorContext error) {
        this.error = error;
    }
}
